package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.service.PaymentProofService;
import com.amsp.oa.oademo.vo.PaymentProofVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "支付证明单管理")
@RestController
@RequestMapping("/api/payment-proof")
public class PaymentProofController {

    @Resource
    private PaymentProofService paymentProofService;

    @ApiOperation("获取支付证明单列表")
    @GetMapping("/list")
    public IPage<PaymentProofVO> getList(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size,
            @RequestParam(required = false) String monthDate) {
        Page<PaymentProofVO> page = new Page<>(current, size);
        IPage<PaymentProofVO> list = paymentProofService.getList(page, monthDate);
        return list;
    }

    @ApiOperation("获取支付证明单详情")
    @GetMapping("/{id}")
    public PaymentProofVO getDetail(@PathVariable Long id) {
        return paymentProofService.getDetail(id);
    }

    @ApiOperation("保存支付证明单")
    @PostMapping("/save")
    public void save(@RequestBody PaymentProofVO vo) {
        paymentProofService.batchSaveOrUpdate(vo);
    }

    @ApiOperation("删除支付证明单")
    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        paymentProofService.delete2(id);
    }

    @ApiOperation("批量删除支付证明单")
    @PostMapping("/batch-delete")
    public void batchDelete(@RequestBody List<Long> ids) {
        paymentProofService.batchDelete2(ids);
    }
}